
function slideImage(){
	var $active = $('#slide IMG.active');
	if($active.length == 0){
		$active = $('#slide IMG:last');
	}
	
	var $next;
	if($active.next().length == false){
		$next = $('#slide IMG:first');
	}else{
		$next = $active.next();
	}
	
	$active.addClass('last-active');
	
	$next.css({opacity: 0.0}).addClass('active')
		.animate({opacity: 1.0}, 2000, function(){
			$active.removeClass('active last-active');
		});
	
}

$(function(){
	setInterval('slideImage()', 3000);
});

//Tao nut Len trang dau tien
$(function(){
	//Ham ScrollTop
	$.fn.scrollToTop=function(){
		$(this).hide().removeAttr("href");
		if($(window).scrollTop()!="0"){
			$(this).fadeIn("slow");
		}
		var scrollDiv=$(this);
		$(window).scroll(function(){
			if($(window).scrollTop()=="0"){
				$(scrollDiv).fadeOut("slow");
			}else{
				$(scrollDiv).fadeIn("slow");
			}
		});
		$(this).click(function(){
			$("html, body").animate({scrollTop:0},"slow");
		});
	};//Ham ScrollTop
	
});

$(function() {
	$("#go_top").scrollToTop();
});

//Hieu ung giu menu o dau
$(document).ready(function() {
 
    var div = $('.menu');
    var start = $(div).offset().top;
 
    $.event.add(window, "scroll", function() {
        var p = $(window).scrollTop();
        $(div).css('position',((p)>start) ? 'fixed' : 'absolute');
        $(div).css('top',((p)>start) ? '0px' : '');
    });
 
});